package com.atguigu.lease.common.mybatisplus;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author GQS @Date 2024/8/27/19:42 @Description
 */
@Configuration
// @MapperScan("com.atguigu.lease.web.*.mapper") // 扫描mapper接口所在的包
public class MybatisPlusConfiguration {
    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        // 创建mybatisplus的拦截器
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        // 创建mp内部自己的分页拦截器
        PaginationInnerInterceptor pagingInnerInterceptor =
            new PaginationInnerInterceptor(DbType.MYSQL);
        // 将分页拦截器注册给MybatisPlusInterceptor
        interceptor.addInnerInterceptor(pagingInnerInterceptor);
        // 返回配置好的mybatisplus拦截器
        return interceptor;
    }
}

